<?php
class LookupBehavior extends CActiveRecordBehavior
{
    public $attribute;
    
    public function beforeSave()
    {
        if (is_array($this->getOwner()->{$this->attribute}))
        {
            $this->getOwner()->{$this->attribute} = var_export($this->getOwner()->{$this->attribute}, true);
        }
    }
    
    public function afterFind()
    {
        if (empty($this->getOwner()->{$this->attribute}) === false)
            $this->getOwner()->{$this->attribute} = $this->evaluateExpression($this->getOwner()->{$this->attribute});
        /*CVarDumper::dump($this->getOwner()->{$this->attribute});
        Yii::app()->end();*/
    }
}